﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Windows.Forms;

namespace QuanLyQuanCaPhe
{
    public partial class frmLogIn : Form
    {
        private string soDay = "";
        public frmLogIn(string soDay)
        {
            InitializeComponent();
            this.soDay = soDay;
        }

        private void btnLogIn_Click(object sender, EventArgs e)
        {
            try
            {
                TaiKhoan taiKhoan = new TaiKhoan(txtID.Text.Trim(), txtPass.Text.Trim());

                string[] para = { "@TenTaiKhoan" };
                string[] values = { taiKhoan.Id };
                DataSet ds = connection_sql.FillDataSet("proc_getQuyen", CommandType.StoredProcedure, para, values, taiKhoan);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    taiKhoan.Quyen = ds.Tables[0].Rows[0]["Quyen"].ToString();
                    //
                    //Đăng nhập thành công
                    //
                    Hide();
                    frmQuanLyCaPhe frmqlcf = new frmQuanLyCaPhe("10", true, taiKhoan.Id);
                    frmqlcf.ShowDialog();
                    Close();
                }
                else
                    lblThongBao.Visible = true;
            }
            catch { }
        }
    }
}
